{{include file="public/header" /}}

{{include file="public/header_top_nav" /}}

{{include file="public/home_search" /}}


<!--个人中心页面 start -不需要body -->

{{include file="public/user_menu" /}}
<form class="am-form form-validation" method="post" action="{{:MyUrl('index/useraddress/save')}}" request-type="ajax-fun" request-value="ViewModalBack">
    <div class="col-lg-9  ftSize16">
        <div class="row hidden-xs">
            <div class="col-lg-12">
                <div class="labelTitle" style="font-size: 18px;" >Agregar Nueva Dirección</div>
            </div>
        </div>
        {{include file="lib/region_linkage" /}}
        <div class="row mTop50">
            <div class="col-lg-12 inFlex">
                <div class="labelTitle">Dirección detallada：</div>
                <div class="mLeft20">
                    <textarea name="address" id="form-address" placeholder="Dirección detallada" class="wd400 form-control">{{if !empty($data['address'])}} value="{{$data.address}}"{{/if}}</textarea>
                </div>
            </div>
        </div>
        <div class="row mTop50">
            <div class="col-lg-12 inFlex">
                <div class="labelTitle">Receptor：</div>
                <div class="mLeft20">
                    <input type="text" name="name" placeholder="Nombre" data-validation-message="Formato de nombre entre 2 ~ 16 caracteres" class="form-control inlineBlock wd130" {{if !empty($data['name'])}} value="{{$data.name}}"{{/if}} required />
                </div>
            </div>
        </div>
        <div class="row mTop50">
            <div class="col-lg-12 inFlex">
                <div class="labelTitle ">número de contacto：</div>
                <div class="mLeft20">
                    <input type="text" class="form-control inlineBlock wd130" name="tel" placeholder="número de contacto" minlength="6" maxlength="30" data-validation-message="Error de formato de teléfono" {{if !empty($data['tel'])}} value="{{$data.tel}}"{{/if}} required />
                </div>
            </div>
        </div>
        <div class="row mTop50">
            <div class="col-lg-12 inFlex alignitemcenter">
                <div class="labelTitle"></div>
                <div class="mLeft20">
                    <input type="checkbox" name="is_default" value="1" {{if isset($data['is_default']) and $data['is_default'] eq 1}}checked="true"{{/if}} />
                    <span>Establecer dirección predeterminada</span>
                </div>
                <div class="mLeft20">
                    <input type="hidden" name="id" {{if !empty($data['id'])}} value="{{$data.id}}"{{/if}} />
                    <button class="btn btn-primary">Ahorrar</button>
                </div>
            </div>
        </div>
</form>
<div class="row mTop50 hidden-xs">
    <div class="col-lg-12 inFlex alignitemcenter">
        <div class="labelTitle">Dirección de recepción</div>
    </div>
</div>
<div class="row mTop20">
    <div class="col-lg-12 inFlex alignitemcenter">
        <table class="table" id="userAddresTab">
            <thead>
            <tr class="tableHead">
                <th>Receptor</th>
                <th>Dirección</th>
                <th>número de contacto</th>
                <th>Operando</th>
            </tr>
            </thead>
            <tbody>
            {{if !empty($user_address_list)}}
            {{foreach $user_address_list as $address}}
            <tr>
                <td>
                    {{if isset($address['is_default']) and $address['is_default'] eq 1}}
                    <span class="am-badge am-badge-success-plain am-radius">Defecto</span>
                    {{/if}}
                    {{$address.name}}
                </td>
                <td>
                    {{$address.province_name}}{{$address.city_name}}{{$address.county_name}}{{$address.address}}
                </td>
                <td>
                    {{$address.tel}}
                </td>
                <td>
                    <a href="javascript:;" class="am-icon-edit address-submit-save" data-url="{{:MyUrl('index/useraddress/saveinfo', ['id'=>$address['id']])}}" data-popup-title="Editar Dirección"> </a>
                    <a href="javascript:;" class="am-icon-trash-o address-submit-delete" data-url="{{:MyUrl('index/useraddress/delete')}}" data-view="reload" data-id="{{$address.id}}"> </a>
                </td>
            </tr>
            {{/foreach}}
            {{/if}}
            </tbody>
        </table>
    </div>
</div>
</div>
<!--个人中心页面 end -不需要body -->

{{include file="public/footer_nav" /}}

<script type="text/javascript">
    // 返回处理
    function ViewModalBack(e) {
        if (e.code == 0) {
            $.AMUI.progress.done();
            Prompt(e.msg, 'success');
            setTimeout(function () {
                location.reload();
            }, 1500);
        } else {
            $('form.form-validation').find('button[type="submit"]').button('reset');
            $.AMUI.progress.done();
            Prompt(e.msg);
        }
    }
</script>

{{include file="public/footer" /}}